fix(beta/tools): raise StopResponse after send_dtmf_events to yield turn#5397
Open
ibiscp wants to merge 1 commit intolivekit:mainfrom
Open
fix(beta/tools): raise StopResponse after send_dtmf_events to yield turn#5397ibiscp wants to merge 1 commit intolivekit:mainfrom
ibiscp wants to merge 1 commit intolivekit:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
IVR (Interactive Voice Response) navigation is one of the primary use cases for voice agents using
send_dtmf_events. In this context, after pressing digits the agent has no meaningful action to take — it must stay silent and listen for the IVR's next prompt. This is not a preference, it is the required protocol: speaking or taking further action before the IVR responds will confuse the system and break the call flow.However, because
send_dtmf_eventsreturns a success string, the LLM receives a tool result and is immediately re-invoked to generate a response. This causes the agent to speak, narrate, or call additional tools before the IVR has had a chance to react to the keypress.The only way to work around this today is to define a separate no-op tool (e.g.
listen_and_wait) that raisesStopResponse, then hardcode in the system prompt that it must be called after every singlesend_dtmf_eventsinvocation. This is unnecessary boilerplate that every IVR agent developer must rediscover and add independently — and it is easy to forget, causing silent, hard-to-debug failures.Fix
StopResponseis the idiomatic LiveKit Agents mechanism to signal that a tool has completed its work and the agent should yield the turn without generating a response. Raising it at the end ofsend_dtmf_eventsencodes the correct behavior directly in the tool, so developers get the right semantics automatically without any prompt engineering or extra tools. The error path still returns a descriptive string so the LLM can be aware of failures and decide whether to retry.Impact
send_dtmf_eventswill need to be updated (no known first-party usage of the return value).StopResponseis already exported fromlivekit.agents.